package com.power.service.impl;

import com.power.common.Contants;
import com.power.dao.DefectAdDao;
import com.power.dao.impl.DefectAdDaoImpl;
import com.power.ov.ResultData;
import com.power.ov.ResultDataTable;
import com.power.pojo.Defecttype;
import com.power.pojo.Sovle;
import com.power.service.DefectAdService;

import java.sql.SQLException;

/**
 * Created/**
 * Created with IntelliJ IDEA.
 * User: lh
 * Date: 2020/10/03 14:32
 * Description:
 * Version: V1.0
 */


public class defectAdServiceImpl implements DefectAdService {

    DefectAdDao defectAdDao=new DefectAdDaoImpl();

    @Override
    public ResultDataTable queryEmployeeList(int currentPage, int pageSize) throws SQLException {
        return defectAdDao.queryEmployeeList(currentPage,pageSize);
    }

    @Override
    public ResultDataTable defectGrade(int currentPage, int pageSize) throws SQLException{
        return defectAdDao.defectGrade(currentPage,pageSize);
    }

    @Override
    public int delDefectById(String defect_state,String defect_id) throws SQLException {
        int newdefect_state=0;
        return defectAdDao.delDefectById(newdefect_state,defect_id);

    }


    @Override
    public ResultData updateDefecttype(Defecttype defecttype) throws SQLException{
        ResultData resultData=new ResultData();
        int res=defectAdDao.updateDefecttype(defecttype);
        if (res>0){
            resultData.setCode(Contants.SUCCESS);
            resultData.setMsg("修改成功");
        }else{
            resultData.setCode(Contants.FAILURE);
            resultData.setMsg("修改失败");
        }
        return resultData;
    }

    @Override
    public int addDefecttype(Defecttype defecttype) throws SQLException {
        return defectAdDao.addDefecttype(defecttype);
    }

    @Override
    public ResultData updateGrade(String defect_grade,String task_id) throws SQLException {
        ResultData resultData=new ResultData();
        int res=defectAdDao.updateGrade(defect_grade,task_id);
        if (res>0){
            resultData.setCode(Contants.SUCCESS);
            resultData.setMsg("修改成功");
        }else{
            resultData.setCode(Contants.FAILURE);
            resultData.setMsg("修改失败");
        }
        return resultData;
    }

    @Override
    public ResultDataTable querySolveTask(int currentPage, int pageSize)throws SQLException {

        return defectAdDao.querySolveTask(currentPage,pageSize);
    }

    @Override
    public int addSovle(Sovle sovle) throws SQLException {

        return defectAdDao.addSovle(sovle);
    }

    @Override
    public ResultData updateYesNo(String sovle_task, int is_delete) throws SQLException {
        ResultData resultData=new ResultData();
        int res=defectAdDao.updateYesNo(sovle_task,is_delete);
        if (res>0){
            resultData.setCode(Contants.SUCCESS);
            resultData.setMsg("修改成功");
        }else{
            resultData.setCode(Contants.FAILURE);
            resultData.setMsg("修改失败");
        }
        return resultData;
    }

    @Override
    public ResultDataTable queryOption() throws SQLException {
        return defectAdDao.queryOption();
    }

    @Override
    public ResultData addSovleAccount(String sovle_account, String sovle_task) throws SQLException {
        ResultData resultData=new ResultData();
        int res=defectAdDao.addSovleAccount(sovle_account,sovle_task);
        if (res>0){
            resultData.setCode(Contants.SUCCESS);
            resultData.setMsg("修改成功");
        }else{
            resultData.setCode(Contants.FAILURE);
            resultData.setMsg("修改失败");
        }
        return resultData;
    }
}
